package com.changgou.task;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class OrderTask {

    @Autowired
    private RabbitTemplate rabbitTemplate;
    /**
     * 自动确认收货,15天后自动确认收货
     *      每一个小时,执行触发一次,检查是否有到期自动收货的订单
     */
    @Scheduled(cron = "0 0 * * * ?")
    public void autoTask(){
        //向消息队列中发送一条消息
        //传递的数据不重要,重要的是,监听器,接收到后,去数据库查询.
        rabbitTemplate.convertAndSend("","order_auto_take","-");
    }
}
